﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;

namespace Harmonic.CommandHost
{
    class Program
    {
        internal static ServiceHost myServiceHost = null;

        static void Main(string[] args)
        {
            try
            {

                ServiceLocator.Build();


                myServiceHost = new ServiceHost(typeof(CqrsService));
                myServiceHost.Open();
                Console.WriteLine("The service is ready at {0}", myServiceHost.BaseAddresses[0]);
                Console.WriteLine("Press <Enter> to stop the service.");
                Console.ReadLine();

                //Uri baseAddress = new Uri("http://localhost:8080/CqrsHost");

                //using (ServiceHost host = new ServiceHost(typeof(CqrsService), baseAddress))
                //{
                //    // Enable metadata publishing.
                //    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                //    smb.HttpGetEnabled = true;
                //    smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                //    host.Description.Behaviors.Add(smb);

                //    // Open the ServiceHost to start listening for messages. Since
                //    // no endpoints are explicitly configured, the runtime will create
                //    // one endpoint per base address for each service contract implemented
                //    // by the service.
                //    host.Open();

                //    Console.WriteLine("The service is ready at {0}", baseAddress);
                //    Console.WriteLine("Press <Enter> to stop the service.");
                //    Console.ReadLine();

                //    // Close the ServiceHost.
                //    host.Close();
                //}
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadLine();
            }
        }
    }
}
